package com.disapand.dingdang.model

import org.ktorm.database.Database
import org.ktorm.entity.Entity
import org.ktorm.entity.sequenceOf
import org.ktorm.schema.*

/**
 * @author disapand
 * @date 2022/2/27 - 19:24 星期日
 */
interface Role : BaseEntity<Role> {
    companion object: Entity.Factory<Role>()

    var id: Int
    var role: String
    var roleName: String

}

object Roles: BaseTable<Role>("d_roles") {
    val id = int("id").primaryKey().bindTo { it.id }
    val role = varchar("role").bindTo { it.role }
    val roleName = varchar("role_name").bindTo { it.roleName }
}

object RolesResources: BaseTable<Nothing>("d_roles_resources") {
    val role = int("role")
    val resource = int("resource")
}

val Database.roles get() = this.sequenceOf(Roles)
val Database.rolesResources get() = this.sequenceOf(RolesResources)